﻿Imports USA411
Public Class HS2_Test

    Dim hs As USA411.HomeSeer2Engine


    Public Property Server() As String
        Get
            Return txtServer.Text
        End Get
        Set(ByVal value As String)
            txtServer.Text = value
        End Set
    End Property

    Public Property UserID() As String
        Get
            Return txtUserID.Text
        End Get
        Set(ByVal value As String)
            txtUserID.Text = value
        End Set
    End Property

    Public Property Password() As String
        Get
            Return _txtPassword.Text
        End Get
        Set(ByVal value As String)
            _txtPassword.Text = value
        End Set
    End Property



    Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        hs = New USA411.HomeSeer2Engine(txtServer.Text, txtUserID.Text, txtPassword.Text)
        pnlTestControls.Enabled = True
        cbX10.SelectedIndex = 3
        cbSDS.SelectedIndex = 3
        cbSDV.SelectedIndex = 3

        UpdateLog()
    End Sub


    Private Sub UpdateLog()
        txtLog.Text = hs.GetLog
    End Sub

    Private Sub btnSetDevice_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXX10.Click
        hs.ExecuteX10(txtDevCode1.Text, cbX10.Text, 50)
        UpdateLog()
    End Sub

    Private Sub btnSDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSDS.Click
        hs.SetDeviceStatus(txtDevCode2.Text, cbSDS.SelectedIndex)
        UpdateLog()
    End Sub

    Private Sub btnSDV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSDV.Click
        hs.SetDeviceValue(txtDevCode3.Text, cbSDV.SelectedIndex)
        UpdateLog()
    End Sub

    Private Sub btnRunScript_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRunEventt.Click
        hs.RunEvent(txtEvent.Text)
        UpdateLog()
    End Sub

    Private Sub HS2_Test_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Me.Hide()
        e.Cancel = True
    End Sub

End Class